Hi, everyone. I made a very simplistic scene manager for you all to use, its somewhat compressed as well. here's an example:
Basically, this scene manager allows you to create init, update and draw for each scene (as well as anything else you want to cook up, of course).
HOW TO USE
to make a new scene, use the command 'nscn' inside of your init function. for example: nscn({init=function() end, update=function() end, draw=function() end})
to grab the current scene thats running so you can modify it or its variables, you can simply create a local variable called 'self'.
local this=scn['self']()
(or local this=scn.self())
to switch to a scene, you'll need to comment the ID of that scene so you don't lose track. I recommend you have a function that launches at the init() of your game that creates all of your scenes for you.
command to load a scene: scn_mng.go(id) where id is the scene number you want to run.
Finally, you need to put the 2 commands inside draw() and update(). in update(), put scn_mng.update() and in draw put scn_mng.draw()
code snippit:
--scene manager --shooting★ scn = {self=function() return scn[scn_mng.r] end} scn_mng = { go=function(s) scn_mng.r = s scn[s].init() end, draw=function() scn[scn_mng.r].draw() end, update=function() scn[scn_mng.r].update() end } function nscn(d) local a={ init=d.init or function() end, update=d.update or function() end, draw=d.draw or function() end } add(scn, a) end |
code example (used in cart above)
--sample function create_scenes() --scene 1 nscn({ init=function() --create a local var called --this and set it to self --scene local this=scn['self']() --create particles this.particles = {} for i=0,16 do local a={rnd(127),rnd(127),rnd(2)} add(this.particles, a) end --create a timer to switch --to scene 2 with this.timer=0 end, update=function() --create a local var called --this and set it to self --scene local this=scn['self']() this.timer+=1 if this.timer==120 then this.timer=0 --switch to scene 2 scn_mng.go(2) end end, draw=function() --create a local var called --this and set it to self --scene local this=scn['self']() --draw particles for i=1,#this.particles do pset(this.particles[i][1], this.particles[i][2], 7) this.particles[i][1]+=this.particles[i][3] this.particles[i][2]+=this.particles[i][3] end end }) --scene 2 nscn({ init=function() --create a local var called --this and set it to self --scene local this=scn['self']() this.timer=0 end, update=function() --create a local var called --this and set it to self --scene local this=scn['self']() this.timer+=1 if this.timer==120 then this.timer=0 --switch back to scene 1 scn_mng.go(1) end end, draw=function() cls(1) end }) end function _init() --create scenes create_scenes() scn_mng.go(1) end function _update() scn_mng.update() end function _draw() cls() scn_mng.draw() print('running scene '..scn_mng.r, 0, 0, 7) end |
I am interested in the future making a game (not even sure if it would be in Unity, Game Maker, Godot, or something else) and having some dusty arcade cabinet that you find - and it has a Pico-8 arcade game on it!
I am wondering how feasible it is for the Pico-8 game to be embedded and how well the game canvas could be moved around and positioned, incorporated into the game, to look like it's in a cabinet, etc., or if it's even possible at all.
its gonna be a race
update:I added more sattelites and a cow (very productive I know).
Still thinking about the gameplay, I think I am going to make them be able to bump into eachother and collide with astroids and maybe sattelites aswell. and when they eventually get to the moon. maybe do a moonlander mini-game or something.
Hi all,
I'm writing a short graphical text adventure for the PICO-8, and a few weeks ago I determined that I needed a vector graphics editor capable of outputting PICO-8 code. I've created a web app called GMagic that lets you make vector drawings on a canvas, then export Lua functions for drawing them. I also provide the functions for drawing polygons and polylines:
ptstr() (needed for the functions):
Polygon:
Polyline:
If you want to read more about GMagic or check out some sample screenshots, you can view the Github repository here. If you end up using GMagic for a cart, I'd love to hear about it!
EDIT 6/24: I can't believe I forgot to include ptstr()! I've added it above, and to the Lua sample in the repo.
The game is a work in progress, but is mechanically complete. Just adding levels and polish at this point.
EDIT: I've got 6 levels so far. I'm going for maybe 10-15, and then I want to add some more SFX and music.
Modified previous work to add a centroid bar to spiral galaxies.
https://en.wikipedia.org/wiki/Barred_spiral_galaxy
Press: "x" to regenerate.
This is a work in progress randomly generated marble game. I have to shout out Eggnog, who made the excellent game PicoPutt. You should go play that, this game is only possible because of his excellent collision methods, and it's not nearly as good.
It's an implementation in pico-8 of the famous puzzle game,
with one of the most beloved rulesets amongst the game's enthusiasts.
WIP.
Today I am starting a new tutorial series on how to make a Roguelike in Pico-8. New episodes will be released throughout February. Hopefully, we will be done before the 7-Day Roguelike Challenge 2019 begins. The series is designed to give you the skills and tools to participate in that challenge.
If you have any questions of feedback you can post them in this thread.
Here are the videos:
#2 - Basic Movement
#3 - Animation
#4 - Token Optimization
#5 - Wall Collision
#6 - Object Interaction
#7 - Text Boxes
#8 - Message System
#9 - Monsters
#10 - Mob System
#11 - Combat
#12 - Simple Pathfinding
#13 - Death
#14 - HP Display
#15 - AI
#16 - Fog of War
#17 - Fog Polish
#18 - Token Tweaks
#19 - Pathfinding
#20 - Path Tweaking
#21 - Inventory UI
#22 - Use Menu
#23 - Equipment
#24 - Eating
#25 - Throw UI
#26 - Throwing
#27 - Gameplay Test
#28 - Random Rooms
#29 - Signature
#30 - Signature Mask
#31 - Worm
#32 - Merging Areas
#33 - Shortcuts
#34 - Stairs
#35 - Floors
#36 - Shepherding
#37 - Hub Floor
#38 - Optimizations
#39 - Tile Borders
#40 - Pretty Walls
#41 - Wall Overlap
#42 - Decorations
#43 - Managing Stats
#44 - More Monsters
#45 - Chests
#46 - Random Food
#47 - Curses
#48 - Stats
#49 - Freestanding
#50 - Bugfixing
Final Video:
A difficult platforming game with a gardening/Splatoon-like twist. Made by Charlie Tran
This is one of my first games, and my longest to date. Please let me know what you think, thanks!
The STG like "LIFE FORCE".
Japanese title is "沙羅曼蛇".
I refferred to Family computer ver.
Main game is WIP.
A tweetcart I made to teach myself what sin() and cos() actually do. I never took trigonometry.
A demake of my game Patrick's Cyberpunk Challenge for the TweetTweetJam.
The object of the game is to move Patrick the Leprechaun around the board and remove all 28 squares. Squares with special symbols will remove extra squares:
Move Patrick to a square using the arrow keys. Note that you can (and sometimes must) move diagonally by pressing two arrow keys simultaneously.
Puzzles might be impossible to solve, and the game doesn't recognize if you win or lose. If the screen is empty except for Patrick, you win! If you have no legal moves, you lose and must restart the game manually.
Source code:
poke(24364,3)x="웃"v="▥"h="▤"b={}for i=1,36 do b[i]=i%9<2 and""or"█"end for i in all{"⬆️","➡️",h,"⬅️","⬇️",v,x}do repeat f=1+flr(rnd(36))until b[f]!=""b[f]=i if(i==x)p=f end::_::t=btnp cls()for i=0,35 do k=b[i+1] ?k,i%9*8,6*flr(i/9)+20,k==x and 11 or 7 end b[p]=""q=p if(t(0))q-=1 if(t(1))q+=1 if(t(2))q-=9 if(t(3))q+=9 if(b[q]and#b[q]>0)p=q t=b[p] if(t=="⬆️"or t==v)b[p-10]=""b[p-9]=""b[p-8]="" if(t=="⬇️"or t==v)b[p+10]=""b[p+9]=""b[p+8]="" if(t=="⬅️"or t==h)b[p-10]=""b[p-1]=""b[p+8]="" if(t=="➡️"or t==h)b[p+10]=""b[p+1]=""b[p-8]="" b[p]=x flip()goto _ |
"Unminified" source code:
--patrick's picochallenge --by tobiasvl --use 64x64 resolution poke(0x5f2c,3) --generate a blank board of --empty █ tiles board={} --the board is 7x4, but we --represent it as a one- --dimensional table. we also --represent it as 36 tiles, ie --a 9x4 grid, with two columns --of "" on each end, so ⬅️➡️▤▥ --tiles don't wrap around when --they destroy adjacent tiles. for i=1,36 do if i%9<2 then --first and last column board[i]="" else board[i]="█" end end --populate the board with tiles --and the player's starting tile tiles={"⬆️","➡️","▤","⬅️","⬇️","▥","웃"} for i in all(tiles) do --find a random tile which is --not in the "invisible" outer --columns repeat position=1+flr(rnd(36)) until board[position]!="" board[position]=i --remember the player if (i=="웃") player=position end --game loop ::_:: cls() --print the board --here's the only obfuscation i --left in: here i loop from --0 to 35, instead of 1 to 36, --because then i only need to --do i+1 once instead of i-1 --twice. for i=0,35 do local tile=board[i+1] --the player is green if tile=="웃" then color(11) else color(7) end --properly centering the board --takes up too many characters --so just an approximation print(tile,i%9*8,6*flr(i/9)+20) end --erase the player character --and destroy the tile board[player]="" --remember the player's position new_player=player --move the player's position if --an arrow key is pressed if (btnp(⬅️)) new_player-=1 if (btnp(➡️)) new_player+=1 if (btnp(⬆️)) new_player-=9 if (btnp(⬇️)) new_player+=9 --if we're still inside the --board proper, ie the tile isn't --nil (outside the board) or "" --(the border columns), make --that the new position. if board[new_player] and board[new_player]!="" then player=new_player tile=board[player] end --if the player lands on one of --the special tiles, destroy --adjacent tiles if tile=="⬆️" or tile=="▥" then --destroy three tiles above board[player-10]="" board[player-9]="" board[player-8]="" end if tile=="⬇️" or tile=="▥" then --destroy three tiles below board[player+10]="" board[player+9]="" board[player+8]="" end if tile=="⬅️" or tile=="▤" then --destroy three tiles left board[player-10]="" board[player-1]="" board[player+8]="" end if tile=="➡️" or tile=="▤" then --destroy three tiles right board[player+10]="" board[player+1]="" board[player-8]="" end --put the player in the new --(or old!) position board[player]="웃" --loop flip() goto _ |
Not a big problem, but probably easy to fix.
If you're in the sprite editor and press Alt+Left to go to the code editor, the cursor will move one space to the left.
The same happens if you're in the music editor and press Alt+Right; the cursor will move to the right.
Here's a strange bug I found. If you write something like this in the code editor:
rectfill(0,0,5,5) |
and you search for 0 with CTRL+F, it will highlight the first 0. If you then press CTRL+G, however, it will fail to find the second one. The same goes for the 5.
From my testing, this seems to only happen with every other occurence. If you search for 0 here:
rectfill(0,0,0,0) |
then CTRL+G will only highlight the first and the third argument.
I've only had it happen with function arguments, and only with single-character arguments; single-letter variable names also have this problem. Putting a space after the commas also makes it behave properly.
It's a bit of a problem when writing tweetcarts where you have little whitespace, short variable names, and want to find variables or number literals to replace while optimizing :)
Originally from Tobiasvl's tweetcart: https://twitter.com/Spug/status/1090559155436511232
(Sorry I didn't include the link before.)